1, "exceptions" => 1);
$uni = new WortschatzUniLeipzigApiWrapper($username, $password, $options);
$design = new Template();
$func = new Functions();
$python_postagger = "/home/www/www.onetipp.com/python/Postagger.py";
$python_neragger = "/home/www/www.onetipp.com/python/Nertagger.py";
$python_ldaprofiler = "/home/www/www.onetipp.com/python/LDAProfiler.py";
$ignorePOS = $func->IgnorePosTags();
// 2: Originaltext im RAM abspeichern -> auf HDD gespeichert
if(strlen($text)>3){
$file = md5(md5($text).md5(uniqid(rand(), true)).time);
$tmp_file = "/home/cache/input/$file.txt";
file_put_contents($tmp_file, $text, LOCK_EX);
// 3: POS Tagging mit RDRPOSTagger.py
$command2 = "/usr/bin/python $python_postagger $tmp_file";
$outputPos = shell_exec($command2." 2>&1");
// 4: Parallel NER Tagging
// $command3 = "/usr/bin/python $python_neragger $tmp_file";
// $outputNer = shell_exec($command3." 2>&1");
//echo "
Exec Command: $command2 -> Debug: $output";
// echo "
Debug: $outputNer ";
// echo json_decode($outputNer);
// 3: POS Tagging mit RDRPOSTagger.py
$command4 = "/usr/bin/python $python_ldaprofiler $tmp_file";
$outputLda = shell_exec($command4." 2>&1");
echo "
Debug LDA Profiler: $outputLda
";
}
// pos tag auswerten
$rawText = explode(" ", $outputPos);
$SynChangedText = "";
/*
preg_match_all('/u\'(.*?)\'/', $outputNer, $matches);
var_dump($matches);
var_dump($outputNer);
var_dump($outputNer);
exit;
foreach (preg_split('/],\s*\[/', trim($outputNer, '[]')) as $row) {
$data = preg_split("/',\s*'/", trim($row, "'"));
print_r($data);
}
exit;
*/
foreach ($rawText as $e){
$t = explode('/', $e);
$to_tmp="";
$word = $t[0];
$pos = $t[1];
$to = $t[0];
//5: POS Tagging dort folgendes mit Synonmye von Uni Leipzig tauschen
//POS Tag GLEICH "NOMEN" oder "Verb" oder "Adjektiv" oder "Adverb"
if ((strcasecmp($pos,"NN")==0 || strcasecmp($pos,"VVFIN")==0 ) && !in_array($pos, $ignorePOS)){
// wir tauschen erstmal nur Substanive & Verben
//echo "Word: $t[0] -> Pos: $t[1] :: ";
try{
$uniWrapper = $uni->Synonyms($word,5);//$uni->Synonyms($t[0], 3);
$random = rand (1, count($uniWrapper));
if(!is_null($uniWrapper)){
$cc = 0;
foreach ($uniWrapper as $u){
if ($random == $cc){
$to_tmp = $u->dataRow[0];
//var_dump($u->dataRow);
}
$cc++;
}
}
$to = " $to_tmp\">$to_tmp";
} catch(Exception $e){
echo "ERROR! ".$e->getMessage()."\n";
}
}
if (strlen($to_tmp)<2){
$SynChangedText .= $word . " ";
} else {
$SynChangedText .= $to . " ";
}
// echo "$counter : Orginal: $t[0]
";
// echo "$counter : Output: $to
";
$counter++;
}
$content = array_merge(
array('robots'=>"INDEX,FOLLOW,ALL"),
array('title'=>"Unique Content Creation by OneTIPP.COM!"),
array('onetipp_original'=>$text),
array('onetipp_results'=>$SynChangedText),
array('onetipp_debug'=>"$output - OneTIPP Version: $mod_date"),
array('description'=>"Kopiere einen Text und erstelle vollautomatisch einen neuen Text - Leistungsschutzkonform und Urheberrechtlich sicher!")
);
$design->setPath("/home/www/www.onetipp.com/tpl-new");
$design->display('startpage_new', $content, true, false);
//echo $design->display_cache('startpage_new', $content, false, false, 3600*24*3);
// automatische Verbindung mit localhost:27017
$mongo = new MongoClient();
// $blog ist ein MongoDB-Objekt (vergleichbar mit MySQL-Datenbank, wird automatisch angelegt)
$blog = $mongo->OnetippProcessingStorage;
// $posts ist eine MongoCollection (vergleichbar mit SQL-Tabelle, wird automatisch angelegt)
$posts = $blog->storeProcessed;
// schreiben
$posts->insert(array(
"inserttimestamp_ms" => round(microtime(true) * 1000),
"inserttimestamp_unix" => time(),
"originalTextInput" => $text,
"finalTextOutput" => $SynChangedText,
"autorprofil_id" => "",
"autorprofil_version" => "0.0.0.0"
));
exit(0);
/*
// connect to mongodb
$m = new MongoClient("mongodb://127.0.0.1:27017",
array(
"socketTimeoutMS" => 100000
)
);
// select a database
$db = $m->OnetippProcessingStorage;
//echo "Database mydb selected";
//$collection = $db->createCollection("storeProcessed");
//echo "Collection created succsessfully";
// select a collection (analogous to a relational database's table)
$c = $m->selectCollection("storeProcessed");
$document = array(
"inserttimestamp_ms" => round(microtime(true) * 1000),
"inserttimestamp_unix" => time(),
"originalTextInput" => $text,
"finalTextOutput" => $SynChangedText,
"autorprofil_id" => "",
"autorprofil_version" => "0.0.0.0"
);
// add a record
$cursor = $c->insert($document)->timeout(60000);
//var_dump($collection);
//var_dump($db);
//echo "Document inserted successfully";
//var_dump($c->getIndexInfo());
exit(0);
*/